﻿using System.Collections.Generic;
using System.Windows;
using Elca.MvvmHelpers;

namespace ULSDeobfuscator {

    public class FilterChoice : BaseNotifyableObject {

        public class FilterChoiceEquatable : IEqualityComparer<FilterChoice>{

            public bool Equals(FilterChoice x, FilterChoice y) {
                // assume both are never null
                return x.ItemName.Equals(y.ItemName);
            }

            public int GetHashCode(FilterChoice obj) {
                return obj.ItemName.GetHashCode();
            }
        }

        private bool _isSelected;
        public bool IsSelected {
            get { return _isSelected; }
            set {
                if (_isSelected != value) {
                    _isSelected = value;
                    OnPropertyChanged("IsSelected");
                }
            }
        }

        private string _itemName;
        private bool _isVisible;

        public string ItemName {
            get { return _itemName; }
            set {
                if (_itemName != value) {
                    _itemName = value;
                    OnPropertyChanged("ItemName");
                }
            }
        }

        public bool IsVisible {
            get { return _isVisible; }
            set {
                if (_isVisible != value) {
                    _isVisible = value;
                    OnPropertiesChanged("IsVisible");
                    OnPropertiesChanged("Visibility");
                }
            }
        }

        public Visibility Visibility {
            get { return _isVisible ? Visibility.Visible : Visibility.Collapsed; }
        }

        public FilterChoice() {
            _isVisible = true;
            _isSelected = true;
        }

        public FilterChoice(FilterChoice fc) {
            _isVisible = fc._isVisible;
            _isSelected = fc._isSelected;
            _itemName = fc._itemName;
        }
    }
}